﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ViewMasterPageMain.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="estudent.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	IzpitniRok
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="JQueryContent" runat="server">
    <script type="text/javascript">
        var predmet;
        $(document).ready(function () {
            $("#profesor").change(function () {
                $("#profesor option[value='prazen']").hide();
                $.post("IzpitniRok/Poisci", $("#kriteriji").serialize(), function (data) {
                    $("#predmet").html(data);

                });
            });


            $("#profesor").change(function () {
                $("#profesor option[value='prazen']").hide();
                $.post("../IzpitniRok/Poisci", $("#kriteriji").serialize(), function (data) {
                    $("#predmet").html(data);
                });
            });


            $("#predmet").change(function () {
                $.post("IzpitniRok/soProfesorji", $("#kriteriji").serialize(), function (data) {
                    $("#dodatniIzvajalci").html(data);
                });

            });

            //v primeru ko imamo napako pri samem vnosu obrazca ali pa se vracamo nazaj na stran z browser back buttonom

            //ko se vracamo nazaj z browser buttonom
            if ($("#profesor").val() != "prazen" && $("#profesor").val() != undefined) {

                $("#profesor option[value='prazen']").hide();
                $.post("IzpitniRok/Poisci", $("#kriteriji").serialize(), function (data) {
                    $("#predmet").html(data);

                });


                if ($("#predmet").val() == "prazen") {

                    $.post("IzpitniRok/getSession", function (data) {

                        $("#predmet").val(data);

                        //pocakajmo nekaj casa
                        setTimeout(function () {
                            $.post("IzpitniRok/soProfesorji", $("#kriteriji").serialize(), function (data) {
                                $("#dodatniIzvajalci").html(data);
                            });

                        }, 1000);


                    });
                }
            } else {
                //ko imamo izbranega profesorja loginanega
                if ($("#predmet").val() != "prazen") {
                    setTimeout(function () {
                        $.post("IzpitniRok/soProfesorji", $("#kriteriji").serialize(), function (data) {
                            $("#dodatniIzvajalci").html(data);
                        });

                    }, 1000);
                }
            }
            ////////////////////////////////////////////

            //ko pride do napake v izponjevanju obrazca
            $("#predmet").change(function () {
                $.post("../IzpitniRok/soProfesorji", $("#kriteriji").serialize(), function (data) {
                    $("#dodatniIzvajalci").html(data);
                });
            });

            if ($("#profesor").val() != "prazen" && $("#profesor").val() != undefined) {

                $("#profesor option[value='prazen']").hide();
                $.post("../IzpitniRok/Poisci", $("#kriteriji").serialize(), function (data) {
                    $("#predmet").html(data);

                });

                if ($("#predmet").val() == "prazen") {
                    setTimeout(function () {
                        $.post("../IzpitniRok/getSession", function (data) {

                            $("#predmet").val(data);

                            setTimeout(function () {
                                $.post("../IzpitniRok/soProfesorji", $("#kriteriji").serialize(), function (data) {
                                    $("#dodatniIzvajalci").html(data);
                                });

                            }, 1000);

                        });
                    }, 1000);
                }

            } else {
                //ko imamo izbranega profesorja loginanega
                if ($("#predmet").val() != "prazen") {
                    setTimeout(function () {
                        $.post("../IzpitniRok/soProfesorji", $("#kriteriji").serialize(), function (data) {
                            $("#dodatniIzvajalci").html(data);
                        });

                    }, 1000);
                }
            }
            ////////////////////////////////////////////


        });

    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="InnerRightContent" runat="server">
<h1>DOLOČI IZPITNI ROK</h1>
<% =Html.ValidationSummary() %>
<form action="/IzpitniRok/Vnos" method="post" id="kriteriji">

  
    <%
        if (ViewData["profesorji"] != null)
        {
            Response.Write(ViewData["profesorji"]);
         %>
         <% =Html.ValidationMessage("profesor", "*")%>
         <%} %>

<label>Predmet: </label>
            <%
                if (ViewData["profesorji"] != null)
                {
                    Response.Write("<select name=\"imePredmeta\" id=\"predmet\" title=\"Izberite predmet\"><option value=\"prazen\">NAJPREJ IZBERITE PROFESORJA</option></select>");%>
                <% =Html.ValidationMessage("imePredmeta", "*")%>
                <%}%>
                <%else
                {
                    Response.Write("<select name='imePredmeta' id='predmet'>");
                    Response.Write("<option value='prazen'>Izberi predmet</option>");
                    foreach (var p in (IEnumerable<sPredmeti>)ViewData["predmeti"])
                    {
                        if(ViewData["predmet"]!=null && ViewData["predmet"].ToString().CompareTo(p.sPredmeta.ToString())==0)
                            Response.Write("<option selected='selected' value='" + p.sPredmeta + "'>" +p.sPredmeta+" - "+p.imePredmeta + "</option>");
                        else
                            Response.Write("<option value='" + p.sPredmeta + "'>" + p.sPredmeta + " - " + p.imePredmeta + "</option>");
                    }
                    Response.Write("</select>");
                }
         %>
         <div id="dodatniIzvajalci"></div>
<label>Datum: </label>

        <select name="dan" title="Izberite dan">
            <%
                for (int i = 1; i < 32; i++)
                {
                    if(ViewData["dan"]!=null && ViewData["dan"].ToString().CompareTo(i+"")==0)
                        Response.Write("<option selected='selected'>" + i + "</option>");
                    else
                        Response.Write("<option>" + i + "</option>");
                }
                 %>
        </select> -

        <select name="mesec" title="Izberite mesec">
            <%
                for (int i = 1; i < 13; i++)
                {
                    if (ViewData["mesec"] != null && ViewData["mesec"].ToString().CompareTo(i + "") == 0)
                        Response.Write("<option selected='selected'>" + i + "</option>");
                    else
                        Response.Write("<option>" + i + "</option>");
                }
                 %>
        </select> -

        <select name="leto" title="Izberite leto">
            <%
                for (int i = 2010; i < 2040; i++)
                {
                    if (ViewData["leto"] != null && ViewData["leto"].ToString().CompareTo(i + "") == 0)
                        Response.Write("<option selected='selected'>" + i + "</option>");
                    else
                        Response.Write("<option>" + i + "</option>");
                }
                 %>
        </select>

<label>Čas izpita: </label>

        <select name="ura" title="Izberite uro izpita">
                                <%
                for (int i = 5; i < 24; i++)
                {
                    if (ViewData["ura"] != null && ViewData["ura"].ToString().CompareTo(""+i) == 0)
                        Response.Write("<option value='" + i + "' selected='selected'>" + String.Format("{0:00}", i) + "</option>");
                    else
                        Response.Write("<option value='" + i + "'>" + String.Format("{0:00}", i) + "</option>");
                }
                 %>
        </select> :
        <select name="minuta" title="Izberite minuto izpita">
                                <%
                for (int i = 0; i <=45; i+=15)
                {
                    if (ViewData["minuta"] != null && ViewData["minuta"].ToString().CompareTo(""+i) == 0)
                        Response.Write("<option  value='" + i + "' selected='selected'>" + String.Format("{0:00}",i) + "</option>");
                    else
                        Response.Write("<option  value='" + i + "'>" + String.Format("{0:00}", i) + "</option>");
                }
                 %>
        </select>
<label>Predavalnica: </label>

        <select name="predavalnica" title="Izberite predavalnico kjer bo izpit">
                    <%
                for (int i = 1; i < 8; i++)
                {
                    if (ViewData["pred"] != null && ViewData["pred"].ToString().CompareTo("P"+i) == 0)
                        Response.Write("<option selected='selected'>P"+ i + "</option>");
                    else
                        Response.Write("<option>P" + i + "</option>");
                }
                 %>
        </select>
<label>Maximalno število točk izpita</label>
<% =Html.TextBox("max",ViewData["max"]) %><% =Html.ValidationMessage("max","*") %>
<label>Število točk za pozitivno oceno</label>
<% =Html.TextBox("meja",ViewData["meja"]) %><% =Html.ValidationMessage("meja","*") %>
        <br />
        <br />
        <hr />
        <br />
<input name="potrdi" type="submit" value="Potrdi" class="button" title="Vnesite izpitni rok"/>

</form>
</asp:Content>

